package biz.alla.market.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import biz.alla.market.domain.Application;
import biz.alla.market.service.MarketService;

@Controller
public class ApplicationController {
    private MarketService marketService;

    protected static final String MODEL_ATTRIBUTE_APPLICATION = "application";
    protected static final String APPLICATION_VIEW = "application";

    @RequestMapping("/application")
    public String showApplicationById(@RequestParam(value = "applicationId", required = true) int applicationId, ModelMap modelMap) {
	Application application = marketService.getApplication(applicationId);
	modelMap.addAttribute(MODEL_ATTRIBUTE_APPLICATION, application);
	
	return APPLICATION_VIEW;
    }

    public void setMarketService(MarketService marketService) {
	this.marketService = marketService;
    }
}
